export default {
	data() {
		return {
			skeletonShow: true,
			// income: '0.00',
			// crashBack: '0.00',
			// profit: '0.00',
			totalSaleAmount: '0.00',
			selfProfit: '0.00'
		};
	},
	computed: {
		statusBar() {
			const { systemInfo: { statusBarHeight } } = this.$store.state
			const menu = uni.getMenuButtonBoundingClientRect()
			const ret = {
				top: statusBarHeight + (menu.top - statusBarHeight),
				height: menu.height + (menu.top - statusBarHeight),
				menuWidth: menu.width + uni.upx2px(14)
			}
			return ret
		}
	},
	mounted() {
		// this.fetchIncomeToday()
		this.fetchFrontData()
	},
	methods: {
		async fetchIncomeToday() {
			const { success, data } = await this.$api.getIncomeTody()
			const { todayCrashBack, todayProfit, todayTotalIncome } = data
			if (success && data) {
				this.income = todayTotalIncome.toFixed(2).toString();
				this.crashBack = todayCrashBack.toFixed(2).toString();
				this.profit = todayProfit.toFixed(2).toString();
			}
		},
		async fetchFrontData() {
			const { success, data } = await this.$api.getFrontData();
			if (success && data) {
				this.totalSaleAmount = data.totalSaleAmount.toFixed(2).toString()
				this.selfProfit = data.selfProfit.toFixed(2).toString()
			}
		},
		HANDLE_JUMP_HOME() {
			uni.switchTab({
				url: '/pages/mall/mall'
			})
		},
		doJump(path, query) {
			const queryStr = []
			if (query) {
				for(const key in query) {
					queryStr.push(`${key}=${query[key]}`)
				}
			}
			uni.navigateTo({
				url: `/pagesA/${path}${queryStr.length ? '?' + queryStr.join('&') : ''}`
			})
		}
	}
}